return [null, null];
}
- _onScreenshotComplete(result, area, stream, file, flash, invocation) {
- if (result) {
- if (flash) {
- let flashspot = new Flashspot(area);
- flashspot.fire(() => {
- this._removeShooterForSender(invocation.get_sender());
- });
- } else {
+ _onScreenshotComplete(area, stream, file, flash, invocation) {
+ if (flash) {
+ let flashspot = new Flashspot(area);
+ flashspot.fire(() => {
this._removeShooterForSender(invocation.get_sender());
- }
+ });
+ } else {
+ this._removeShooterForSender(invocation.get_sender());
}
stream.close(null);
clipboard.set_content(St.ClipboardType.CLIPBOARD, 'image/png', bytes);
}
- let retval = GLib.Variant.new('(bs)', [result, filenameUsed]);
+ let retval = GLib.Variant.new('(bs)', [true, filenameUsed]);
invocation.return_value(retval);
}
screenshot.screenshot_area(x, y, width, height, stream,
(o, res) => {
try {
- let [result, area] =
+ let [success_, area] =
screenshot.screenshot_area_finish(res);
this._onScreenshotComplete(
- result, area, stream, file, flash, invocation);
+ area, stream, file, flash, invocation);
} catch (e) {
- invocation.return_gerror(e);
+ this._removeShooterForSender(invocation.get_sender());
+ invocation.return_value(new GLib.Variant('(bs)', [false, '']));
}
});
}
screenshot.screenshot_window(includeFrame, includeCursor, stream,
(o, res) => {
try {
- let [result, area] =
+ let [success_, area] =
screenshot.screenshot_window_finish(res);
this._onScreenshotComplete(
- result, area, stream, file, flash, invocation);
+ area, stream, file, flash, invocation);
} catch (e) {
- invocation.return_gerror(e);
+ this._removeShooterForSender(invocation.get_sender());
+ invocation.return_value(new GLib.Variant('(bs)', [false, '']));
}
});
}
screenshot.screenshot(includeCursor, stream,
(o, res) => {
try {
- let [result, area] =
+ let [success_, area] =
screenshot.screenshot_finish(res);
this._onScreenshotComplete(
- result, area, stream, file, flash, invocation);
+ area, stream, file, flash, invocation);
} catch (e) {
- invocation.return_gerror(e);
+ this._removeShooterForSender(invocation.get_sender());
+ invocation.return_value(new GLib.Variant('(bs)', [false, '']));
}
});
}
gpointer task_data,
GCancellable *cancellable)
{
- cairo_status_t status;
ShellScreenshot *screenshot = SHELL_SCREENSHOT (object);
ShellScreenshotPrivate *priv;
g_autoptr (GOutputStream) stream = NULL;
g_autoptr(GdkPixbuf) pixbuf = NULL;
g_autofree char *creation_time = NULL;
+ GError *error = NULL;
g_assert (screenshot != NULL);
if (!creation_time)
creation_time = g_date_time_format (priv->datetime, "%FT%T%z");
- if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL,
- "tEXt::Software", "gnome-screenshot",
- "tEXt::Creation Time", creation_time,
- NULL))
- status = CAIRO_STATUS_SUCCESS;
- else
- status = CAIRO_STATUS_WRITE_ERROR;
+ gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, &error,
+ "tEXt::Software", "gnome-screenshot",
+ "tEXt::Creation Time", creation_time,
+ NULL);
- g_task_return_boolean (result, status == CAIRO_STATUS_SUCCESS);
+ if (error)
+ g_task_return_error (result, error);
+ else
+ g_task_return_boolean (result, TRUE);
}
static void